<ListBox x:Class="TagFlo.PhotoScroller"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Background="DarkGray" 
	SelectionChanged="PhotoScroller_SelectionChanged" ItemTemplate="{DynamicResource ScrollViewerItemTemplate}" 
	PreviewKeyDown="PhotoScroller_PreviewKeyDown" MouseDown="PhotoScroller_MouseDown"
		 >
	<ListBox.Resources>
		
		<Style x:Key="PhotoListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
				<Setter Property="OverridesDefaultStyle" Value="true"/>
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="ListBoxItem">
							<Border  Name="Border"  Padding="2" SnapsToDevicePixels="true">
								<ContentPresenter />
							</Border>

							<ControlTemplate.Triggers>
								<Trigger Property="IsSelected" Value="true">
									<!--<Setter TargetName="Border" Property="Background" Value="{StaticResource SelectedBackgroundBrush}"/>-->

									<Setter TargetName="Border" Property="BitmapEffect">
										<Setter.Value>
											<OuterGlowBitmapEffect GlowColor="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" GlowSize="10" />
										</Setter.Value>

									</Setter>
								</Trigger>

							</ControlTemplate.Triggers>
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Style>



			<SolidColorBrush x:Key="WindowBackgroundBrush" Color="#FFF" />
		<SolidColorBrush x:Key="SolidBorderBrush" Color="#888" />
		<SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#EEE" />
		<SolidColorBrush x:Key="DisabledBorderBrush" Color="#AAA" />
		<DataTemplate x:Key="ScrollViewerItemTemplate">


			<Grid Width="75" Height="75"	  
				VerticalAlignment="Center" HorizontalAlignment="Center" Margin="6">

				<Border Padding="4"  BorderBrush="#22000000" Background="White" BorderThickness="1" CornerRadius="4" >

					
						<Image Source="{Binding Path=Thumbnail}" Width="65" Height="65"/>




					<Border.ToolTip>
						<TextBlock x:Name="PhotoItemText" >
							<TextBlock.Text>
								<Binding Mode="OneWay" Path="Rating" />
							</TextBlock.Text>
						</TextBlock>
					</Border.ToolTip>

				</Border>


			</Grid>


		</DataTemplate>
		
		

	</ListBox.Resources>
	<ListBox.Style>
		<Style x:Key="{x:Type ListBox}" TargetType="ListBox">
			<Setter Property="SnapsToDevicePixels" Value="true"/>
			<!--<Setter Property="OverridesDefaultStyle" Value="true"/>-->
			<Setter Property="SelectionMode" Value="Single"/>
			<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
			<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
			<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
			<Setter Property="MinWidth" Value="120"/>
			<Setter Property="MinHeight" Value="95"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="ListBox">

						
						<Grid x:Name="PhotoScrollerGrid">
							<Grid.RowDefinitions>
								<RowDefinition  Height="*"/>
								<RowDefinition Height="Auto"/>
							</Grid.RowDefinitions>

							<Image x:Name="LargeImage"  Grid.Row="0" Stretch="Uniform"  >
								<Image.ContextMenu>
									<ContextMenu>
										<MenuItem Header="Open"/>
										<MenuItem Header="Edit"/>
									</ContextMenu>
								</Image.ContextMenu>
							</Image>
							<Expander Grid.Row="1" ExpandDirection="Up">
							<ScrollViewer  Margin="0"  >
								<VirtualizingStackPanel Orientation="Horizontal" IsItemsHost="True"/>
							</ScrollViewer>
							</Expander>
						</Grid>

						<ControlTemplate.Triggers>

							<Trigger Property="IsGrouping" Value="true">
								<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>


		</Style>
	</ListBox.Style>

</ListBox>
